package com.xk857.article.controller.pub;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xk857.article.req.ArticleListREQ;
import com.xk857.article.service.IArticleService;
import com.xk857.entities.Article;
import com.xk857.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章信息表 前端控制器
 *
 * @author CV大魔王
 * @since 2021-02-21
 */
@Api(value = "文章管理接口(公共)", tags = "文章管理接口(公共)")
@RestController
@RequestMapping("/pub/article")
public class PubArticleController {

    @Autowired
    private IArticleService articleService;


    @ApiImplicitParam(name = "id", value = "文章ID", required = true)
    @ApiOperation("更新浏览次数")
    @PutMapping("/viewCount/{id}")
    public Result updateViewCount(@PathVariable("id") String id) {
        return articleService.updateViewCount(id);
    }


    @ApiOperation("公开且已审核的文章列表接口")
    @PostMapping("/list")
    public IPage<Article> list(@RequestBody ArticleListREQ req) {
        return articleService.findListByLabelIdOrCategoryId(req);
    }
}
